import DS from 'ember-data';
import Ember from 'ember';
import BaseModel from './base-model';
/*客户*/
var consult = BaseModel.extend({
  pathConfiger: Ember.inject.service("path-configer"),
  dateService: Ember.inject.service("date-service"),
  createDateTime: DS.attr('number'),//创建时间
  advTel: DS.attr('number'),//咨询人电话
  advContent: DS.attr('string'),//咨询内容
  advDate: DS.attr('number'),//咨询日期
  advGender: DS.belongsTo('dicttype'),//咨询人性别,1男2女
  advGoal: DS.attr('string'),//咨询目的
  advName: DS.attr('string'),//咨询人姓名
  advWay: DS.belongsTo('dicttype'),//获取机构信息途径
  appointmentDate: DS.attr('number'),//预约参观日期
  care: DS.attr('string'),//重点关心
  consultChannel: DS.belongsTo('dicttype'),//咨询方式
  receiveStaff: DS.belongsTo('user'),//接待员工
  dietRequirements: DS.attr('string'),//饮食要求
  discontent: DS.attr('string'),//不满意的地方
  customerAddr: DS.attr('string'),//老人住址
  customerBrith: DS.attr('number'),//老人生日
  customerCardCode: DS.attr('number'),//老人身份证号
  customerConsumingAbility: DS.attr('string'),//老人消费水平
  customerTel: DS.attr('number'),//老人电话
  customerEducation: DS.belongsTo('dicttype'),//老人教育级别
  customerGender: DS.belongsTo('dicttype'),//老人性别,1男2女
  customerName: DS.attr('string'),//老人名字
  customerNative: DS.belongsTo('dicttype'),//老人籍贯
  customerPS: DS.attr('string'),//老人身体状况
  consultRelation: DS.belongsTo('dicttype'),//咨询人与老人关系
  customerSelfCareAbility: DS.belongsTo('dicttype'),//老人自理能力
  customerNationality: DS.belongsTo('dicttype'),//老人名族
  occupancyIntent: DS.attr('string'),//入住意向
  consultStatus: DS.belongsTo('dicttype'),//咨询状态
  otherRequirements: DS.attr('string'),//其他要求
  psychologicalPrice: DS.attr('string'),//心理价格
  review: DS.attr('string'),//参观感受
  roomRequirements: DS.attr('string'),//房屋要求
  serviceRequirements: DS.attr('string'),//服务要求
  heartStaff: DS.belongsTo('user'),//孝心助理
  remark: DS.attr('string'),//备注
  backVistInfos:DS.hasMany('backvist'),//对应回访表
  //咨询日期
  advDateComputed:Ember.computed("advDate",function(){
    var advDate=this.get("advDate");
    if(!advDate){
      return null;
    }
    return this.get("dateService").timestampToTime(advDate);
  }),
  advDateString:Ember.computed("advDate",function(){
    var advDate=this.get("advDate");
    return this.get("dateService").formatDate(advDate,"yyyy-MM-dd");
    }),
  //预约入住日期
  appointmentDateComputed:Ember.computed("appointmentDate",function(){
    var appointmentDate=this.get("appointmentDate");
    if(!appointmentDate){
      return null;
    }
    return this.get("dateService").timestampToTime(appointmentDate);
  }),
  appointmentDateString:Ember.computed("appointmentDate",function(){
    var appointmentDate=this.get("appointmentDate");
    return this.get("dateService").formatDate(appointmentDate,"yyyy-MM-dd");
    }),
  customerBrithDate:Ember.computed("customerBrith",function(){
    var customerBrith=this.get("customerBrith");
    if(!customerBrith){
      return null;
    }
    return this.get("dateService").timestampToTime(customerBrith);
  }),
  customerBrithString:Ember.computed("customerBrith",function(){
    var customerBrith=this.get("customerBrith");
    return this.get("dateService").formatDate(customerBrith,"yyyy-MM-dd");
    }),
  //是否已预订
  computedStatus:Ember.computed("consultStatus",function(){
    var consultStatus=this.get("consultStatus");
    if(consultStatus.get("typecode")=="consultStatus3"){
      return true;
    }else{
      return false;
    }
    // var str="";
    // if(consultStatus.get("typecode")=="consultStatus3"){
    //   str+="已预订";
    // }else {
    //   str+='<a {{action "jumpAdvance" consult on="click"}}>'+"咨询转预定"+"</a>";
    // }
    // return str;
  }),
});
export default consult;
